<template>
  <!-- 账号设置 -->
  <div>
    <div class="header">账号注销操作</div>
    <div class="mainpadding">
      <div class="titletext">请知晓一下几点</div>
      <ul class="tabtext hui margin-top3">
        <li>1、账号下已有印章、文件模板将失效</li>
        <li>2、与企业的组织关系将失效</li>
        <li>3、账号下待签署的文件将无法继续签署</li>
        <li>4、个人主体下已签署的文件将无法在线出证</li>
      </ul>
      <div class="tabtext margin-top3">点击注销账号代表您同意<span class="lan pointer" @click="agreement">《大鸿签账号注销协议》</span></div>
      <div class="margin-top3">
        <el-button type="primary" @click="cancelAccount">注销账号</el-button>
      </div>
    </div>
    <el-dialog title="大鸿签账号注销协议" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <div v-html="content" class="scroll fwbxontent"></div>
    </el-dialog>
  </div>
</template>

<script>
import { deleteUserPhone, getAgreement } from "@/api/userinfo"
import Cookies from "js-cookie";
export default {
    inject: ['closeloading'],
  data() {
    return {
      content: "",
      dialogVisible:false
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    handleClose(done){
      done()
    },
    init() {
      getAgreement().then(res => {
        this.closeloading()
        this.content = res.result.data.agreement
      })
    },
    agreement() {
      this.dialogVisible = true
      // this.$alert(this.content, '大鸿签账号注销协议', {
      //   dangerouslyUseHTMLString: true
      // }).then(() => {
      // }).catch(action => {
      // });
    },
    cancelAccount() {
      this.$confirm('此操作将永久删除改账号信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        deleteUserPhone({
          userId: Cookies.get('admin_id')
        }).then(res => {
          if (res.code == 200) {
            this.$message({
              type: 'success',
              message: '注销成功!'
            });
            this.$store.dispatch("user/logout").then(res => {
              location.reload()
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        });
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.header {
  height: 50px;
  border-bottom: 1px solid #e4e4e4;
  line-height: 50px;
  padding-left: 30px;
}
</style>